package com.lovo.middleman.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.middleman.bean.CustomerBean;
import com.lovo.middleman.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    ICustomerService iCustomerService;

    @RequestMapping("/getCustomerPage")
    public Page<CustomerBean> getCustomerPage(int curPage,
                                              int pageSize,
                                              String customerName,
                                              String customerBusinessScope){

       return iCustomerService.selectCustomerPageItem(curPage,pageSize,customerName,customerBusinessScope);
    }

    @RequestMapping("/getCustomerBean")
    public CustomerBean getCustomerBean(int customerId){
        return iCustomerService.selectById(customerId);
    }

    @RequestMapping("/updateCustomerBean")
    public void updateCustomerBean(@RequestBody CustomerBean customerBean){
        iCustomerService.updateCustomer(customerBean);
    }

    @RequestMapping("/addCustomerBean")
    public void addCustomerBean(@RequestBody CustomerBean customerBean){
        iCustomerService.addCustomer(customerBean);
    }
}
